# Library
library(streamgraph)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(streamgraph)
 library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3     ✓ purrr   0.3.4
## ✓ tibble  3.0.6     ✓ stringr 1.4.0
## ✓ tidyr   1.1.2     ✓ forcats 0.5.0
## ✓ readr   1.4.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
# Create data:
data <- read_csv("/Users/aniketsingh/Desktop/music/pop.csv")
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   year = col_double(),
##   popularity = col_double(),
##   Genre = col_character()
## )
library(ggplot2)
library(dplyr)

data$year <- as.integer(data$year)
data$popularity <- as.double(data$popularity)
data$Genre <- as.factor(data$Genre)    

normalize <- function(x) {
return ((x - min(x)) / (max(x) - min(x))) }
data$popularity <- normalize(data$popularity)



p1 <- streamgraph(data, key="Genre", value="popularity", date="year", height="300px", width="1000px")
p1
## Warning in widget_html(name = class(x)[1], package = attr(x, "package"), :
## streamgraph_html returned an object of class `list` instead of a `shiny.tag`.
streamgraph(data = data,"Genre", "popularity", "year", interactive = TRUE) %>%
    sg_axis_x(10, "year", "%Y") %>%
    sg_fill_tableau() %>%
    sg_legend(show=TRUE, label="Genre: ")
## Warning in widget_html(name = class(x)[1], package = attr(x, "package"), :
## streamgraph_html returned an object of class `list` instead of a `shiny.tag`.
p2 <- streamgraph(data, key="Genre", value="popularity", date="year" ,interpolate="linear" ,
    width="400px", height="300px"
    )
p2
## Warning in widget_html(name = class(x)[1], package = attr(x, "package"), :
## streamgraph_html returned an object of class `list` instead of a `shiny.tag`.
streamgraph(data, key="Genre",  value="popularity", date="year",
            offset = "expand") %>%
  sg_axis_x(2, "year", "%Y") %>%
  sg_fill_tableau("cyclic") %>%
  sg_legend(show=TRUE, label= "Genre: ") %>%
  sg_annotate(label="Pop/Rock", x = "",y=0.91, color="#ffffff", size=18) %>%
  sg_annotate(label="Mach and Elec", x = "", y=0.6, color="#ffffff", size=18) %>%
  sg_annotate(label="Intermediate Goods",x = "", y=0.48, color="#ffffff", size=18) %>%
  sg_annotate(label="Consumer Goods",x = "",  y=0.29, color="#ffffff", size=18) %>%
  sg_annotate(label="Capital Goods", x = "", y=0.09, color="#ffffff", size=18)
## Warning in widget_html(name = class(x)[1], package = attr(x, "package"), :
## streamgraph_html returned an object of class `list` instead of a `shiny.tag`.
# Shape: stacked barplot
p3 <- streamgraph(data, key="Genre", value="popularity", date="year" ,interpolate="step" ,
    width="400px", height="300px"
    )
p3
## Warning in widget_html(name = class(x)[1], package = attr(x, "package"), :
## streamgraph_html returned an object of class `list` instead of a `shiny.tag`.
library(viridis)
## Loading required package: viridisLite
library(hrbrthemes)
## NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
##       Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
##       if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow
ggplot(data, aes(x=year, y=popularity, fill=Genre)) + 
    geom_area(alpha=0.6 , size=.5, colour="white") +
    scale_fill_viridis(discrete = T) +
    theme_ipsum() + 
    ggtitle("Music Evolution")

#imports the required libraries
library(ggplot2)
library(hrbrthemes)
library(viridis)
library(tidyverse)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
 p<-data%>%
     ggplot(aes(x=year, y=popularity, fill=Genre, text=Genre))+
     geom_area()+
     scale_fill_viridis(discrete = T)+
     theme(legend.position = 'none')+
     theme_ipsum()+
     ggtitle('Evolution of Music')
 ggplotly(p, tootltip='text')
ggplot(data, aes(x=year, y=popularity, fill=Genre))+geom_area() 

library(ggplot2)
library(dplyr)
library(plotly)
library(hrbrthemes)
ggplot(data, aes(x=year, y=popularity, group=Genre, color=Genre)) +
    geom_line()